Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Implement set_attribute & set_class_attribute nonfungibles trait functions for Uniques pallet #9206

Closed

Conversation

iorveth
Copy link

@iorveth iorveth commented Jun 25, 2021

Implements missing set_attribute, set_class_attribute nonfungibles Mutate trait functions for uniques pallet
Relates to #9208

@cla-bot-2021
Copy link

cla-bot-2021 bot commented Jun 25, 2021

User @iorveth, please sign the CLA here.

@iorveth iorveth changed the title Implement set_attribute & set_class_attribute nonfungibles trait functions for Uniques pallet Implement set_attribute & set_class_attribute nonfungibles trait functions for Uniques pallet Jun 25, 2021
@bkchr bkchr added the B0-silent Changes should not be mentioned in any release notes label Jun 28, 2021
@stale
Copy link

stale bot commented Jul 28, 2021

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Jul 28, 2021
@bkchr bkchr removed the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Jul 28, 2021
frame/uniques/src/impl_nonfungibles.rs Show resolved Hide resolved
}
class_details.total_deposit.saturating_accrue(deposit);
if deposit > old_deposit {
T::Currency::reserve(&class_details.owner, deposit - old_deposit)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
T::Currency::reserve(&class_details.owner, deposit - old_deposit)?;
T::Currency::reserve(&class_details.owner, deposit.saturating_sub(old_deposit))?;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion, done here 6fabf25

Copy link
Member

@shawntabrizi shawntabrizi Aug 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is NOT needed, and actually probably some additional overhead.

Note the check just 1 line above: deposit > old_deposit

This subtraction can never panic

please undo

if deposit > old_deposit {
T::Currency::reserve(&class_details.owner, deposit - old_deposit)?;
} else if deposit < old_deposit {
T::Currency::unreserve(&class_details.owner, old_deposit - deposit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
T::Currency::unreserve(&class_details.owner, old_deposit - deposit);
T::Currency::unreserve(&class_details.owner, old_deposit.saturating_sub(deposit));

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion, done here 6fabf25

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo

let mut deposit = Zero::zero();
if !class_details.free_holding && maybe_check_owner.is_some() {
deposit = T::DepositPerByte::get()
.saturating_mul(((key.len() + value.len()) as u32).into())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.saturating_mul(((key.len() + value.len()) as u32).into())
.saturating_mul((key.len().saturating_add(value.len()) as u32).into())

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion, done here 6fabf25

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one i think is okay, but would want you to look closer before actually making this change

and then a test

@iorveth iorveth requested a review from apopiak July 29, 2021 11:33
@danforbes
Copy link
Contributor

Looking forward to having this in the main branch...thanks for the enhancement @iorveth! This relates to #9208.

@shawntabrizi
Copy link
Member

This looks okay, but I suggest we do not increase the expectations of the Mutate trait, and instead introduce a new trait which inherits from Mutate called MutateWithMetadata or something.

Remember that we should not assume all (or even most) NFT systems will require some on-chain metadata.

@stale
Copy link

stale bot commented Sep 6, 2021

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Sep 6, 2021
@stale stale bot closed this Sep 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. B0-silent Changes should not be mentioned in any release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants